#include<stdio.h>
#include<stdlib.h>
#include"list.h"

typedef struct{
    int data;
    struct list_head list;
}my_data;

int main(){
    LIST_HEAD(head);    // 静态；

    struct list_head *head2 = malloc(sizeof(struct list_head));
    INIT_LIST_HEAD(head2);   //动态

    my_data data1 = {1};
    my_data data2 = {2};
    my_data data3 = {3};
    my_data data4 = {4};
    my_data data5 = {5};
    my_data data6 = {6};
    my_data data7 = {7};
    my_data data8 = {8};

    list_add(&data1.list, &head);
    list_add(&data2.list, &head);
    list_add(&data3.list, &head);
    list_add(&data4.list, &head);

    list_add(&data5.list, head2);
    list_add(&data6.list, head2);
    list_add(&data7.list, head2);
    list_add(&data8.list, head2);

   // list_add(&data1.list, head2);
   // list_add(&data2.list, head2);
    //list_add(&data3.list, head2);
   // list_add(&data4.list, head2);

    my_data *tmp;
    list_for_each_entry(tmp, &head, list){
        printf("%d\n", tmp->data);
    }


    list_for_each_entry(tmp, head2, list){
        printf("%d\n", tmp->data);
    }

    free(head2);
    return 0;
}